package leetcode.sword;

import java.util.ArrayList;
import java.util.Arrays;

public class Solution61 {

    public static void main(String[] args) {
//        int[] nums = {3,0,1,2,5};
//        System.out.println(isStraight(nums));
        ArrayList a = new ArrayList();
//        a.add(1);
        a.add(0,2);
//        System.out.println((int)a.get(0)+","+(int)a.get(1));

    }

    public static boolean isStraight(int[] nums) {
        //先排序
        Arrays.sort(nums);
        //看看有几个0
        int i = 0;
        while(nums[i]==0){ //最多有两个王（0）
            i++;
        }
        //此时i指向第一个非零数下标
        int zeroNum = i;
        while(i<4){
            zeroNum -= nums[i+1]-nums[i]-1;
            if(zeroNum<0) return false;
            i++;
        }
        return true;
    }
}
